package com.remon.quartz.service.impl;

import com.remon.quartz.dao.QrtzCronTriggersResp;
import com.remon.quartz.entity.QrtzCronTriggers;
import com.remon.quartz.entity.QuartzTriggers;
import com.remon.quartz.service.QrtzCronTriggersService;
import com.remon.quartz.vo.PageRes;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 触发器表达式逻辑处理类
 *
 * @author remon
 * @create 2018-09-08 23:46
 **/
@Service
@Log
public class QrtzCronTriggerServiceImpl extends BaseService implements QrtzCronTriggersService {

    /**
     * 触发器表达式数据库操作对象
     */
    private final QrtzCronTriggersResp qrtzCronTriggersResp;

    @Autowired
    public QrtzCronTriggerServiceImpl(QrtzCronTriggersResp qrtzCronTriggersResp) {
        this.qrtzCronTriggersResp = qrtzCronTriggersResp;
    }

    /**
     * 获取数据库中的触发器表达式
     *
     * @param pageNo   当前页
     * @param pageSize 每页条数
     * @param params   筛选参数
     * @return 返回分页对象 @link{PageRes}  @link{ QuartzTriggers }
     */
    @Override
    public PageRes<QrtzCronTriggers> pages(Integer pageNo, Integer pageSize, Map<String, Object> params) {
        return new PageRes<>(qrtzCronTriggersResp.findAll(getPageable(pageNo, pageSize)));
    }
}
